package com.dgcsxy.my_college_note.controller;

import com.dgcsxy.my_college_note.common.utils.ResponseResult;
import com.dgcsxy.my_college_note.service.FileUploadService;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @ClassName Yjx
 * @date 2022/10/27 20:14
 * @Version 1.0
 */
@RestController
@RequestMapping("/api/file")
@CrossOrigin
public class McnFileController {

    private final FileUploadService fileUploadService;

    public McnFileController(FileUploadService fileUploadService) {
        this.fileUploadService = fileUploadService;
    }

    /**
     * 日记文件上传
     * @param file
     */
    @PostMapping("/log")
    public ResponseResult logUpload(@RequestParam("file") MultipartFile file) {
        String message = fileUploadService.logUpload(file);
        return ResponseResult.SUCCESS(message);
    }

    /**
     * 封面文件上传
     * @param file
     */
    @PostMapping("/skin")
    public ResponseResult skinUpload(@RequestParam("file") MultipartFile file) {
        String message = fileUploadService.skinUpload(file);
        return ResponseResult.SUCCESS(message);
    }

}
